package com.example.demo.thread.pool;

import java.util.concurrent.*;

/**
 * @author Code Farmer
 * @date 2020/5/30 15:02
 */
public class ThreadPoolDemo {

    public static void main(String[] args) {

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                2, 3, 6000, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5),
                Executors.defaultThreadFactory());

        for (int i = 0; i < 9; i++) {
            threadPoolExecutor.execute(new Task(i));
        }
    }
}
